package reco.db.validation;

import java.util.List;

import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;

public class FieldErrors {

    private final List<FieldError> errors = Lists.newLinkedList();

    public int getErrorCount() {
        return this.errors.size();
    }

    public boolean hasErrors() {
        return !this.errors.isEmpty();
    }

    public void register(FieldError fieldError) {
        this.errors.add(Preconditions.checkNotNull(fieldError, "fieldError"));
    }

    public void discardErrors() {
        this.errors.clear();
    }

}
